<?php

namespace App\Models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    use HasFactory;

    /**
     * Prepare a date for array / JSON serialization.
     *
     * @param  \DateTimeInterface  $date
     * @return string
     */
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function admins()
    {
        return $this->belongsTo(Admin::class, 'admin_id');
    }

    public function users()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function blinds()
    {
        return $this->belongsTo(Blind::class, 'blind_id');
    }

    public function shops()
    {
        return $this->belongsTo(Shop::class, 'shop_id');
    }

    public function statuslabel()
    {
        return $this->belongsTo(Dicdata::class, 'status', 'value')
            ->where('typeCode', '=', 'order_status');
    }
}
